import 'package:flame/components.dart';
import 'package:flutter/material.dart';

class BackGround extends PositionComponent {
  late final Sprite? bgSprite;
  late Rect? bgRect;

  BackGround() {
    init();
  }

  void init() async {
    bgSprite = await Sprite.load('new_map.webp');
  }

  Future<void> onLoad() async {
    
  }

  @override
  void render(Canvas canvas) {
    super.render(canvas);
    bgSprite?.renderRect(canvas, bgRect ?? Rect.zero);
  }

  @override
  void onGameResize(Vector2 vec) {
    super.onGameResize(vec);
    bgRect = Rect.fromLTWH(0, 0, vec.storage.first, vec.storage.last);
  }
}
